package com.htl.computer_network;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;

public class URL__test {
    public static void main(String[] args) throws Exception {
        URL url = new URL("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbpic.588ku.com%2Felement_origin_min_pic%2F16%2F08%2F19%2F1457b6a76c7756c.jpg&refer=http%3A%2F%2Fbpic.588ku.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1635817797&t=1513473ddf770f0dbc92881f355e5151");
        InputStream inputStream = url.openStream();
        OutputStream outputStream = new FileOutputStream("D:\\Project" +
                "\\IDEA_project\\java_note\\src\\com\\htl" +
                "\\computer_network\\myPicture.png");
        int temp = 0;
        while ((temp = inputStream.read()) != -1){
            outputStream.write(temp);
        }
        inputStream.close();
        outputStream.close();
    }
}
